# -*- coding: utf-8 -*-
from django.contrib import admin
from models import News
#from pygameweb.comments.admin import CommentInline

from django.contrib.flatpages.models import FlatPage
from django.contrib.flatpages.admin import FlatPageAdmin as FlatPageAdminOld


class NewsAdmin(admin.ModelAdmin):
    # list options
    list_display = ('title', 'creator', 'created', 'last_edited', 'active')
    list_display_links = ('title',)
    list_editable = ('active',)
    list_filter = ('active', 'created')
    date_hierarchy = 'created'
    # editing options
    fieldsets = (
        (None, {
            'fields':(('title', 'active'),'slug', 'markup', 'content')
            }),
        )
    prepopulated_fields = {"slug": ("title",)}

    #inlines = [CommentInline]
    
    def save_model(self, request, obj, form, change):
        if not change:
            obj.creator = request.user
        obj.last_editor = request.user
        obj.save()

admin.site.register( News, NewsAdmin )

from django.utils.translation import ugettext_lazy as _

class FlatPageAdmin(FlatPageAdminOld):
    fieldsets = (
            (None, {'fields': ('url', 'title', 'content', 'sites')}),
            (_('Advanced options'), {'classes': ('collapse',), 
             'fields': ('registration_required', 'template_name')}),
    )
    class Media:
        js = ('js/jquery.js',
              'admin/js/tiny_mce/tiny_mce.js',
              'admin/js/tiny_mce/textareas.js',)


# We have to unregister it, and then reregister
admin.site.unregister(FlatPage)
admin.site.register(FlatPage, FlatPageAdmin)
